<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button>点击获取短信验证码</button>
    <script>
        // 获取button按钮元素 
        var btn = document.getElementsByTagName('button')[0];
        // 定时器  
        // innerText
        var flag = true;
        btn.onclick = function(){
            if(flag==false){
                return
            }
            var count = 10; //倒计时数字
            btn.innerText = `${count}s重新获取`;
            flag = false;
            var timer = setInterval(function(){
                count--;
                btn.innerText = `${count}s重新获取`;
                if(count<0){
                    clearInterval(timer);
                    btn.innerText = `点击获取验证码`;
                    flag = true;
                }
            },1000);

        }
    </script>
</body>
</html>